
package online.xuping.thousandsOfWorlds.common.snowflake;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ID生成器
 *
 * @author dongyinggang
 * @date 2022/10/20 15:18
 * @copyright 2022 山东新北洋信息技术股份有限公司. All rights reserved
 */
@Configuration
public class IdGenderConfig {

    @Value("${snowflake.workerId}")
    private Long workerId;
    @Value("${snowflake.dataCenterId}")
    private Long dataCenterId;


    /**
     * 初始化雪花ID生成器的bean
     *
     * @return {@link SnowflakeIdWorker }
     * @author dongyinggang
     * @date 2022/10/21 16:00
     **/
    @Bean
    public SnowflakeIdWorker getSnowflakeIdWorker() {
        return new SnowflakeIdWorker(workerId, dataCenterId);
    }


}
